<link rel="stylesheet" href="/styles/thickbox.css" />
<script type="text/javascript" src="/scripts/thickbox.js"></script>
<div class="ModuleHig">
	<div class="pad_t15 pad_115">
	<span>&nbsp;&nbsp;&nbsp;</span>
	<a id="various1" href="#inline1" >AddGroup</a>
	
</div>
<div class="clear hig20"></div>
<div style="display: none;">
		<div id="inline1" style="width:600px; min-height:500px; padding:10px 10px;">
		<div class="PopUp">
		<form enctype="multipart/form-data" id="messageform" name="messageform" method="POST" action="/expressions/index/addgroup" >
		<p class="Title">Addgroup</p>
		<div id="Compose">
			<div class="pad_t8">
			<label>Name</label><input type="text" id="Name" name="Name" value="" />
			<div class="clear"></div>
			</div>
			<div class="pad_t8">
			<label>Logo</label><input type="file" id="file" name="file"/>
			<div class="clear"></div>
			</div>
			<div class="pad_t8">
			<label>&nbsp;</label><p><b>Note: Upload only jpg, jpeg, gif, png files. (Max upload size: 3MB)</b></p>
			<div class="clear"></div>
			</div>
			<div class="pad_t8">
			<label>Description</label><textarea name="message" id="message"></textarea>
			<div class="clear"></div>
		</div>
		<div class="pad_t8 pad_1108">
		<a class="Button" href="javascript:void(0);" onclick="addgroup(document.messageform);"><span>Add</span></a>
		</div>
		<div class="clear"></div>
		</div>
		</form>
		</div>
		</div>
	</div>
<?php if(count($ctx->result['result'])>0){?>
  <div class="pad_t15 pad_15 txt_sm"><div class="Fleft pad_15"><input name="Check_All" type="checkbox" id="Check_All" onClick="CheckAll(document.getElementsByName('check_list[]'))"/><label style="margin:-5px 0 5px 5px;">Check All</label>
   </div>
   </div>
<div class="clear"></div>


<?php $i=0; while($i<count($ctx->result['result'])){ ?>
<div class="Anon">
<input type="checkbox" name="check_list[]" id="check_list" value="<?php echo $ctx->result['result'][$i]['group_id'];?>"/>
<div class="blkCont">
<p class="UserImg"><img src="/images/GroupDef.gif" /></p>
</div>
<div class="blkCont">
<p class="Title"><a href="/expressions/index/groupview/<?php echo base64_encode($ctx->result['result'][$i]['group_id']); ?>"><?php echo $ctx->result['result'][$i]['name']; ?></a></p>
</div>
<div class="blkCont">
</div>
<div class="blkCont" style="float:right;">
<?php if($ctx->result['result'][$i]['status']==0)			
	  {
		$label="Enable";
		$status=1;
	}else{
		$label="Disable";
		$status=0;
		}
?>
<a class="Button" href="javascript:void(0);" onclick="changeStatus(<?php echo $status;?>,<?php echo $ctx->result['result'][$i]['group_id'];?>);"><span><?php echo $label; ?></span></a>
<a id="editgroup" href="javascript:void(0);" onclick="editGroup(<?php echo $ctx->result['result'][$i]['group_id'];?>);">Edit</a>
</div>

<div class="clear"></div>
</div>
<?php $i++; }?>
<div class="pad_t15 pad_115"><a class="Button" href="javascript:void(0);" onclick="changeStatus(0,'');"><span>Disable</span></a>&nbsp;&nbsp;<a class="Button" href="javascript:void(0);" onclick="changeStatus(1,'');"><span>Enable</span></a></div>
<? } else {?>
<p style="padding:50px 50px"><b><center>No Groups</center></b></p>
<? } ?>
</div>
	
	<script type="text/javascript">
//<![CDATA[

function CheckAll(chk)

{
	if(document.getElementById('Check_All').checked)
	{
		var ids="";
		for (i = 0; i < chk.length; i++){
		chk[i].checked = true ;
		}
	}
	else
	{
		for (i = 0; i < chk.length; i++)
		chk[i].checked = false ;
	}
}

function addgroup(frm)
{

   //alert(frm.Name);return false;
	var result = false;
	var result1 = false;
	//alert(frm.file.value);return false;
	result = !isEmpty(frm.Name, "Please Enter name") ;

		if(result) result = !isEmpty(frm.message, "Please enter description") ;
	if(result)
	{
		document.getElementById('messageform').submit()
	}
	 //alert(result);
	//return result;
}
function changeStatus(valStatus,ind)
{
   //alert(ind);return false;
	if(ind=='') {
		var val = '';
		$('#check_list:checked').each(function(i){
		  val+= $(this).val()+',';
		});
		if(val == '')
		{
			alert('Please select a group');
			return false;
		}
	} else {
		val = ind;
	}
	//alert(val);return false;
	//alert("checked"+val);return false;
	$.ajax({
			   
			   type: "POST",
			   dataType: "json",
			   data: "val="+valStatus+"&values="+val,
			   url: "/expressions/index/changegroup-status/",
			    success: function(data){
					//alert(data.output);return false;
					location.reload();					
					}


			});
	
}
function editGroup(val)
{
	tb_show('Edit Group','/expressions/index/editgroup?&val='+val+'&height=400&width=600','');
}
function changegroupstatus(val,action)
{
	//alert(val+"   "+action);return false;
	$.ajax({
			   //alert(action);return false;
			   type: "POST",
			   dataType: "json",
			   data: "val="+val+"&type="+action+"",
			   url: "/expressions/index/changegroup-status/",
			    success: function(data){
					//alert(data.output);return false;
					location.reload();					
					}


			});
	
}
//]]>
</script>
